package com.per.mybootall.hadoop;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;


/**
 * Created with IntelliJ IDEA.
 *
 * @author: yyy
 * Date: 2021/10/21
 * Time: 11:35
 * Description:windows操作hadoop的话，win的本机要配置hosts映射，本地也要有hadoop的简单环境和一些相关的东西
 */
@Component
@EnableScheduling
public class HadoopTest {

    @Value("${hadoop.url}")
    private String hadoopUrl;

//    @Scheduled(cron = "0/10 * * * * ?")
//    public void testFileExist() throws IOException {
//        System.out.println("开始执行hadoop文件判断--------------------------------------------------》》》》》》》》》》》》》》》》》》》");
//        String fileName=hadoopUrl+"/yyy.txt";
//        Configuration configuration=new Configuration();
//        FileSystem fileSystem= FileSystem.get(configuration);
//        if(fileSystem.exists(new Path(fileName))){
//            System.out.println("文件存在");
//        }else{
//            System.out.println("文件不存在");
//        }
//    }
}
